/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2009 INRIA
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Author: Guillaume Seguin <guillaume@segu.in>
 */

#ifndef MULTI_THREADING_PARTITION_H
#define MULTI_THREADING_PARTITION_H

#include "ns3/scheduler.h"
#include "ns3/nstime.h"
#include "ns3/event-id.h"

#include "ns3/ptr.h"
#include "ns3/assert.h"
#include "ns3/log.h"
#include "ns3/object-factory.h"
#include "ns3/synchronizer.h"
//#include "ns3/atomic.h"

#include <errno.h>
#include <pthread.h>
#include <queue>
#include <map>
#include <list>
#include "ns3/atomic.h"

namespace ns3 {

struct MultiThreadingPartition
{
  struct EventMessage {
    uint32_t from;
    uint64_t timestamp;
    EventImpl *event;
  };

  typedef std::queue<EventMessage> EventMessages;

  uint32_t id;
  uint32_t rank;
  uint64_t minDelay;

  uint64_t minMessageTs;
  pthread_mutex_t eventMessagesLock;
  EventMessages eventMessages;
  uint32_t nMessages;

  Scheduler *events;
  Ptr<Synchronizer> synchronizer;

  uint32_t currentUid;
  uint32_t uid;
  uint64_t currentTs;
};

} // namespace ns3

#endif /* MULTI_THREADING_PARTITION_H */
